﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace NewCROStarter
{
    class CheatEngine
    {
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern bool ReadProcessMemory(
          IntPtr hProcess,
          IntPtr lpBaseAddress,
          [Out] byte[] lpBuffer,
          int dwSize,
          out int lpNumberOfBytesRead
         );
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern bool WriteProcessMemory(
            IntPtr hProcess,
            IntPtr lpBaseAddress,
            byte[] lpBuffer,
            uint nSize,
            out int lpNumberOfBytesWritten);
        [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
        static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

        //读取指针的值，支持嵌套指针，PointerLevel指示应循环多少层指针，即读取第一级地址值，作为指针再去读取其中的值
        static bool ReadPointer(int PointerLevel, IntPtr hProcess, IntPtr lpBaseAddress, out byte[] lpBuffer, int dwSize, out int lpNumberOfBytesRead)
        {
            lpBuffer = new byte[] { 0x00 };
            lpNumberOfBytesRead = 0;
            return true;
        }
    }
}
